//CS330 Forrest Turner, Luke Krantz

//package edu.oregonstate.eecs.cs331.assn1;

import java.io.FileNotFoundException;
import java.io.IOException;
import javax.swing.JFrame;

/**
 * This class "has the main" and as such, is in charge of putting the content of
 * the MazePanel onto the screen (in a manner that utilizes a java application).
 * This allows us to utilize the same internal classes to represent a java
 * applet quite easily.
 */
public class MazeViewer {

	/**
	 * This function is responsible for creating a MazePanel, and inserting its
	 * content pane into a frame (which it also creates).
	 * 
	 * @param args
	 *            filename where a maze description can be found
	 */
	public static void main(String[] args) {

		try {
			if (args.length < 2) {
				System.out
						.println("Usage: MazeViewer <maze file> <search mode>");
				System.exit(-1);
			}
			MazePanel panel = new MazePanel(args[0], args[1]);
			JFrame frame = new JFrame();
			frame.setSize(50 + MazePanel.maxX * MazeCell.CELL_W, 140
					+ MazePanel.maxY * MazeCell.CELL_H);

			panel.setVisible(true);
			frame.getContentPane().add(panel);
			frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
			frame.setVisible(true);
		} catch (FileNotFoundException e) {
			System.out.println(e.getMessage());
			e.printStackTrace();
		} catch (IOException e) {
			System.out.println(e.getMessage());
			e.printStackTrace();
		}
	}
}
